HWJ13_BallBounce
Create an applet called HWJ13_BallBounce starter code here. Have the ball:
- appear at a random location on the screen
- Have the ball move originally in a random direction.
- Add code so that every 40 times it moves the color changes (between any color you want).
- Add a button that stops the animation and a button to start the animation.
Advanced
- Make the ball get slightly bigger and smaller as the animation goes on (like a beating heart).
- Get slighly faster as the time goes on.
- A little bit of randomness so that the ball does not always go in a diamond pattern
Game for Advanced
- Copy the ball so that you have 3 bouncing around the screen.
- Make it a game (maybe have a square that you control and avoid it, maybe...)
Hints:
- Have these global variables
int ballX,ballY, changeInX, changeInY, ballSize
- Remember there are 20 frames a second. So if we want 2 seconds, ti would be 40 frames; we might have a statement if (frames%40==0)
|